/**
 * 
 */
package com.ilock.action;

import java.util.HashMap;
import java.util.Map;

import com.ilock.bean.Iuser;
import com.ilock.service.IUserService;
import com.opensymphony.xwork2.ActionSupport;

/**
 * @author Administrator
 *
 */
public class LoginAction extends ActionSupport {
	
	private IUserService IUserService;
	private String useremail;
	private String userpassword;
	public Map responseJson;  

	public void setIUserService(IUserService IUserService){
		this.IUserService = IUserService;
	}
	
	public Map getResponseJson() {  
        return responseJson;  
    }
	
    public void setResponseJson(Map responseJson) {  
        this.responseJson = responseJson;  
    }
    



	public String getUseremail() {
		return useremail;
	}

	public void setUseremail(String useremail) {
		this.useremail = useremail;
	}

	public String getUserpassword() {
		return userpassword;
	}

	public void setUserpassword(String userpassword) {
		this.userpassword = userpassword;
	}

	public String execute()throws Exception{
		Iuser account = new Iuser();
		Map<String,Object> map = new HashMap<String, Object>();
		account = IUserService.checkIn(useremail, userpassword);
		if(account!=null){
			map.put("user", account);
			map.put("state", "loginSuccess");	
		}else{
			map.put("state", "loginFail");
		}
		this.setResponseJson(map);
		return "success";
		
		
		
	}

}
